using UnityEngine;
using System.Collections;

public class Wood : MonoBehaviour {
	
	
	
	private bool m_isConquered = false;
	private bool m_isControlled = false;//does Player stand on?
	
	public WoodType woodType = WoodType.General; 
	
	private RotateByGravity[] m_rotByG;
	
	void Start(){
		transform.tag = "wood";
		if(transform.root.GetComponentsInChildren<RotateByGravity>()!=null)
			m_rotByG = transform.root.GetComponentsInChildren<RotateByGravity>();
		Debug.Log("Wood Comp Count : "+m_rotByG.Length);
	}
	
	void Update(){
		if(!m_isControlled){
			
			if(m_isConquered){
				//Drag Wood Implement...
				//TODO: Drag ,then Rotate This
				
			}
			
		}		
		
	}
	//Call When Player Enter This Wood
	public void EnterWood(){	
		if(woodType == WoodType.CanBeConquered){
			m_isConquered = true;
		}
		m_isControlled = true;
		foreach(RotateByGravity _rotByG in m_rotByG){
			_rotByG.enabled = false;
		}
		//m_rotByG.enabled = false;
	}
	//Call When Player Leave This Wood
	public void LeaveWood(){
		
		m_isControlled = false;
		foreach(RotateByGravity _rotByG in m_rotByG){
			_rotByG.enabled = true;
		}
		//m_rotByG.enabled = true;
	}
	
	
}

public enum WoodType{
	General,
	CanBeConquered
}